package com.wh.utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class MybatisUtils {

    private static SqlSessionFactory sqlSessionFactory;

    static {
        String resource="mybatis-config.xml";
        InputStream in = MybatisUtils.class.getClassLoader().getResourceAsStream(resource);
        sqlSessionFactory=new SqlSessionFactoryBuilder().build(in);
    }

    public static SqlSession getSqlSession(){
        return sqlSessionFactory.openSession();
    }
}
